package com.jilefojing.beans.enums.forrsourcecorrelation;

import java.util.HashMap;
import java.util.Map;
import com.alibaba.fastjson.JSONObject;


/**
 * 
 * @author 作者 jgshun
 * @date   创建时间 2016年07月26日 12时41分43秒
 */
public enum RelationTypeEnumForRSourceCorrelation {
		/**
		 * (short) 1, "安卓"
		 */
		 	ANDROID((short) 1, "安卓"),
		/**
		 * (short) 2, "苹果"
		 */
		 	IOS((short) 2, "苹果");

	private short code;
	private String msg;

	private RelationTypeEnumForRSourceCorrelation(short code, String msg) {
		this.code = code;
		this.msg = msg;
	}

	public short getCode() {
		return code;
	}

	public void setCode(short code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	@Override
	public String toString() {
		if (this != null) {
			Map<String, Object> allMap = new HashMap<String, Object>();
			allMap.put("code", this.code);
			allMap.put("msg", this.msg);
			String result = JSONObject.toJSONString(allMap);
			result = result.replaceAll("\"", "'");
			return result;
		}
		return super.toString();
	}
	
	public static RelationTypeEnumForRSourceCorrelation getRelationTypeEnumByCode(short code) {
		for (RelationTypeEnumForRSourceCorrelation _enum : RelationTypeEnumForRSourceCorrelation.values()) {
			if (_enum.getCode() == code) {
				return _enum;
			}
		}
		return null;
	}
}
